home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 263_02 / mony.c < prev    next >
Text File  |  1990-02-13  |  1KB  |  40 lines

  1. #include <stdio.h>
  2. #include <c_wndw.h>
  3. #include <c_ndx.h>
  4.  
  5. /*
  6. *    Copyright 1989, Marietta Systems, Inc.
  7. *    All rights reserved
  8. */
  9.  
  10. /*
  11. *     This program demonstrates the use of the mony functions to enter
  12. *    and display monetary figures with two decimal places.
  13. *    This is a simple speadsheet function with entry of quantity and
  14. *    unit price fields.  The program figures the extended price and
  15. *    keeps a running total.
  16. */
  17.  
  18. void main ()
  19. {
  20.      mony ext_price, price = 0, total = 0;
  21.      int quantity = 0, x, ret;
  22.      clr_scrn ("Show mony fields");
  23. /* Build column headings */
  24.      display ("Quantity    Price  Ext Price       Total", 1, 1, high);
  25. /* Accept columns */
  26.      for (x = 2, ret = ENTER ; ret != QUIT ; x++)
  27.      {
  28.           set_crsr (x, 3);
  29.           ret = acptint (&quantity, c_number, alt_high, 4);
  30.           if (ret == QUIT) break; else set_crsr (x, 10);
  31.           ret = acptmony (&price, c_number, alt_high, 4);
  32.           if (ret == QUIT) break;
  33.           ext_price = quantity * price; /* extended price */
  34.           dispmony (ext_price, x, 19, reverse, c_number, 6);
  35.           total += ext_price; /* running total */
  36.           dispmony (total, x, 31, reverse, c_number, 7);
  37.      }
  38.      goodbye (0);
  39. }
  40.